package com.smart.common.utils;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

public class HttpRequestUtils {
	
	public  static void printRequestParams(HttpServletRequest request) {
		
		Enumeration<String> parameterNames = request.getParameterNames();
		while(parameterNames.hasMoreElements()) {
			String nextElement = parameterNames.nextElement();
			String parameter = request.getParameter(nextElement);
			System.out.println(nextElement+"="+parameter);
		}
		Map<String, String[]> parameterMap = request.getParameterMap();
		for(Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
			String key2 = entry.getKey();
			String[] value = entry.getValue();
			System.out.println(key2);
		}
		
	}
	public  static Map<String,String> getParams(HttpServletRequest request) {
		Map<String,String> map = new HashMap<String,String>();
		Enumeration<String> parameterNames = request.getParameterNames();
		while(parameterNames.hasMoreElements()) {
			String key = parameterNames.nextElement();
			String value = request.getParameter(key);
			map.put(key,value);
		}
		return map;
	}

}
